<?php
include("../includes/DBFunctions.php");
include("../includes/GXMLParser.php");

function removeEventFromRegionFunctor( $env, $rid ) {
	$db = new DBFunctions;
	$db->connectDB();
	$result = $db->query("call removeEventFromRegion(".$env.",".$rid.",@a)" );
	$errors = $db->query("SELECT @a");
	while( $line = mysqli_fetch_array( $errors, MYSQL_ASSOC ) ) {
		$error = $line['@a'];
	}
	if( !$result || $error != 0 ) {
		die("alert('Failed stored procedure call (removeEventFromRegion ErrorCode:".$error.")');");
	}
}

if( !isset( $_POST['selectEnvironment'] ) ) {
	die( "Select species was not set.");
}
$env = $_POST['selectEnvironment'];
if( !isset( $_POST['selectRegion'] ) ) {
	die( "Select region was not set.");
}
$rid = $_POST['selectRegion'];

removeEventFromRegionFunctor( $env, $rid );
?>